/* 
 * File:   Sprite.h
 * Copyright (C) 2008, 2009
 *		J. Daniel Expósito Polo (HellSpawn666)
 *		Sergio Padrino Recio (PadrinatoR)
 *
 * Created on 28 de agosto de 2008, 17:46
 *
 * This file is part of BombProject.
 * 
 * BombProject is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
   
 * BombProject is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with BombProject.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _SPRITE_H
#define	_SPRITE_H

#include <SDL/SDL.h>

/**
 * Represents a drawable <b>static</b> sprite.
 * @see AnimatedSprite
 */
class Sprite {
protected:
	bool mChanged, mVisible, mHorizontalMirrored, mVerticalMirrored;
	Sint16 mX, mY, mHeight, mOffsetX, mOffsetY;
	Sint16 mHotPointX, mHotPointY;
	Sint16 mRealHotPointX, mRealHotPointY;
	double mAngle;
	double mScaleX, mScaleY;
	Sint16 mImageWidth, mImageHeight;
	Sint16 mAlpha;
	SDL_Surface *mOriginalSurface, *mTransformedSurface;
public:
	/**
	 * Describes the three possible mirror modes.<br>
	 * <b>MIRROR_ON</b> enables the sprite mirroring.<br>
	 * <b>MIRROR_OFF</b> disables the sprite mirroring.<br>
	 * <b>MIRROR_SWITCH</b> toggles between the previous mirror modes.
	 * @see horizontalMirror, verticalMirror
	 */
	enum MirrorMode {
		MIRROR_ON = 1,
		MIRROR_OFF = 2,
		MIRROR_SWITCH = 3,
	};
	
	/**
	 * Describes the relative positions for a hot point.<br>
	 * <b>HP_TOP</b> top of the sprite.<br>
	 * <b>HP_VCENTER</b> vertical center.<br>
	 * <b>HP_BOTTOM</b> bottom of the sprite.<br>
	 * <b>HP_LEFT</b> left of the sprite.<br>
	 * <b>HP_HCENTER</b> horizontal center.<br>
	 * <b>HP_RIGHT</b> right of the sprite.
	 * @see setHotPoint
	 */
	enum HotPointPosition {
		HP_TOP=1, HP_VCENTER, HP_BOTTOM,
		HP_LEFT, HP_HCENTER, HP_RIGHT
	};
        
public:
	//Creates a new non-animated Sprite using the provided Image.
	Sprite(SDL_Surface *image);
	virtual ~Sprite() = 0;

	int draw(SDL_Surface *surface);
	void horizontalMirror(Sprite::MirrorMode);
	void verticalMirror(Sprite::MirrorMode);
	void rotate(double degrees);
	void turn(double degrees);
	void move(Sint16 dx, Sint16 dy, Sint16 dh = 0);
	void scale(double factor_x, double factor_y);

	void setHotPoint(Sint16 x, Sint16 y);
	void setHotPoint(Uint16 hotpoint_relative = HP_HCENTER | HP_VCENTER);
	void setVisible(bool visible);
	void setAlpha(Sint16 alpha);
	void setX(Sint16 x);
	void setY(Sint16 y);
        void setOffsetX(Sint16 x);
        void setOffsetY(Sint16 y);
	void setHeight(Sint16 h);
	void setPosition(Sint16 x, Sint16 y, Sint16 h = 0);
        void setZ(Sint16 z);

	bool isVisible();
	Sint16 getAlpha();
	Sint16 getX();
	Sint16 getY();
	Sint16 getZ();
        Sint16 getOffsetX();
        Sint16 getOffsetY();
        Sint16 getRealX();
        Sint16 getRealY();
	Sint16 getHeight();
	
	virtual void destroy();

protected:
	void notifyChange();
	void updateSurface();
};
#endif	/* _SPRITE_H */

